package com.ruoyi.kong.controller;

import java.util.List;

import com.ruoyi.kong.domain.KongxSystemProfile;
import com.ruoyi.kong.service.IKongxSystemProfileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * kong配置信息Controller
 * 
 * @author ruoyi
 * @date 2021-08-27
 */
@RestController
@RequestMapping("/kong/param/profile")
public class KongxSystemProfileController extends BaseController
{
    @Autowired
    private IKongxSystemProfileService kongxSystemProfileService;

    /**
     * 查询kong配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:list')")
    @GetMapping("/list")
    public TableDataInfo list(KongxSystemProfile kongxSystemProfile)
    {
        startPage();
        List<KongxSystemProfile> list = kongxSystemProfileService.selectKongxSystemProfileList(kongxSystemProfile);
        return getDataTable(list);
    }

    /**
     * 导出kong配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:export')")
    @Log(title = "kong配置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(KongxSystemProfile kongxSystemProfile)
    {
        List<KongxSystemProfile> list = kongxSystemProfileService.selectKongxSystemProfileList(kongxSystemProfile);
        ExcelUtil<KongxSystemProfile> util = new ExcelUtil<KongxSystemProfile>(KongxSystemProfile.class);
        return util.exportExcel(list, "kong配置信息数据");
    }

    /**
     * 获取kong配置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(kongxSystemProfileService.selectKongxSystemProfileById(id));
    }

    /**
     * 新增kong配置信息
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:add')")
    @Log(title = "kong配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KongxSystemProfile kongxSystemProfile)
    {
        return toAjax(kongxSystemProfileService.insertKongxSystemProfile(kongxSystemProfile));
    }

    /**
     * 修改kong配置信息
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:edit')")
    @Log(title = "kong配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KongxSystemProfile kongxSystemProfile)
    {
        return toAjax(kongxSystemProfileService.updateKongxSystemProfile(kongxSystemProfile));
    }

    /**
     * 删除kong配置信息
     */
    @PreAuthorize("@ss.hasPermi('kong:profile:remove')")
    @Log(title = "kong配置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kongxSystemProfileService.deleteKongxSystemProfileByIds(ids));
    }
}
